package values.tech
{
import framework.dao.EntryUtil;

import values.common.CostValue;

/**
 * TechLevelValue
 * @author jliang
 *
 */
public class TechLevelValue
{
	[Data(type="field", mapping="@index")]
	public var index:int;
	
	[Data(type="field", mapping="params")]
	public var params:*;
	
	public function getNumbericParam(key:String):Number
	{
		return isNaN(Number(params[key])) ? 0 : Number(params[key]);
	}
	
	[Data(type="field",  mapping="cost")]
	public var baseCostDef:*;
	
	protected var _cost:CostValue;
	
	public function get cost():CostValue
	{
		if (!_cost)
		{
			_cost = EntryUtil.mapping(baseCostDef, CostValue);
			_cost.owner = this;
		}
		return _cost;
	}
	
}
}